﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace SLNGP.Core.Individuals
{
    public class Generation :  List<IIndividual>, IGeneration
    {
        public Generation()
        {
        }

        public bool ContainsIndividualWithSameGenome(IIndividual newIndividual)
        {
            return this.Any(i => i.GetStringDisplay() == newIndividual.GetStringDisplay());
        }

        public bool TryAddUnique(IIndividual NewIndividual)
        {
            if (!ContainsIndividualWithSameGenome(NewIndividual))
            {
                this.Add(NewIndividual);
                return true;
            }
            else
            {
                return false;
            }
        }

        public object FitnessData { get; set; }
    }
}